package info.qingshui.browser.hk.setting;


import info.qingshui.browser.*;

import info.qingshui.browser.R;


import android.os.Bundle;
import android.preference.*;
import android.preference.Preference.OnPreferenceChangeListener;


//@TODO http://www.cnblogs.com/keyindex/articles/1814506.html
public class SettingActivity extends PreferenceActivity implements
		OnPreferenceChangeListener {

	private CheckBoxPreference mCheckBoxPre;
	
	private ListPreference  font ;
	
	
//	private RadioGroup fontRadioGroup; 
//	private RadioButton fontSmall;
//	private RadioButton fontMiddle;
//	private RadioButton fontBig;
	

	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.setting);
		mCheckBoxPre = (CheckBoxPreference) findPreference(Setting.USE_PROXY_KEY);
		mCheckBoxPre.setOnPreferenceChangeListener(this);

		font = (ListPreference) findPreference(Setting.FONT_KEY);
		font.setOnPreferenceChangeListener(this);
//		fontSmall = (RadioButton) findViewById(R.id.fontSmall);
//		fontMiddle = (RadioButton) findViewById(R.id.fontMiddle);
//		fontBig = (RadioButton) findViewById(R.id.fontBig);
//		fontRadioGroup = (RadioGroup) findViewById(R.id.fontRadioGroup);
//		RadioGroup.OnCheckedChangeListener mFontChangeRadio = new 
//		    RadioGroup.OnCheckedChangeListener() { 
//				@Override 
//				public void onCheckedChanged(RadioGroup group, int checkedId) { 
//					// TODO Auto-generated method stub 
//					if(checkedId==fontSmall.getId()) { 
//						showSth( fontSmall.getText().toString() );
//					}  else if(checkedId==fontMiddle.getId())  { 
//						showSth( fontMiddle.getText().toString() );
//					} else if(checkedId==fontBig.getId())  {  
//						showSth( fontBig.getText().toString() );
//					}
//				}
//			};  
//		fontRadioGroup.setOnCheckedChangeListener(mFontChangeRadio);
	}

	public boolean onPreferenceChange(Preference preference, Object newValue) {
		if (preference.getKey().equals(Setting.USE_PROXY_KEY)) {
			//mCheckBoxPre.setChecked((Boolean) newValue);
		} else if (preference.getKey().equals(Setting.FONT_KEY)) {

			//showSth(preference.getEditor().toString());
		} else {
			//Toast.makeText(this, preference.getKey(), Toast.LENGTH_SHORT).show();
		}
		return true;//保存
	}

//	private void doSomething(int i) {
//		// TODO Auto-generated method stub
//		if (i == 1) {
//			Toast.makeText(this, "checked!", Toast.LENGTH_SHORT).show();
//		} else if (i == 0) {
//			Toast.makeText(this, "unchecked!", Toast.LENGTH_SHORT).show();
//		}
//	}
	
//	private void showSth(String sth) {
//		Toast.makeText(this, sth, Toast.LENGTH_SHORT).show();
//	}
	


}
